<template>
    <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label="用户名" prop="userName">
        <el-input
            v-model="queryParams.userName"
            placeholder="请输入用户名"
            clearable
            @keyup.enter.native="handleQuery"
        />
        </el-form-item>
        
        <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="用户名" align="center" prop="userName" />
        <el-table-column label="性别" align="center" prop="sex" />
        <el-table-column label="年龄" align="center" prop="age" />
        <el-table-column label="太阳膜" align="center" prop="solarFilm" />
        <el-table-column label="太阳膜自定义尺寸" align="center" prop="solarFilmSize" />
        <el-table-column label="改色膜" align="center" prop="colorChangeFilm" />
        <el-table-column label="改色膜自定义尺寸" align="center" prop="colorChangeFilmSize" />
        <el-table-column label="漆面膜" align="center" prop="lacquerFilm" />
        <el-table-column label="漆面膜自定义尺寸" align="center" prop="lacquerFilmSize" />
        <el-table-column label="盒型" align="center" prop="boxType" />
        <el-table-column label="主体颜色" align="center" prop="color" />

        <el-table-column label="主体颜色自定义" align="center">
            <template #default="{row}">
                <el-image :src="row.colorCustomize" style="width: 40px"
                        :preview-src-list="[row.colorCustomize]"
                        preview-teleported
                />
            </template>
        </el-table-column>

        <el-table-column label="主体颜色占比" align="center" prop="colorProportion" />
        <el-table-column label="主体颜色占比自定义" align="center" prop="colorProportionCustomize" />
        <el-table-column label="风格" align="center" prop="style" />
        <el-table-column label="风格自定义" align="center" prop="styleCustomize" />
        <el-table-column label="包装体现" width="200" align="center" prop="packagingReflects" />
        <el-table-column label="特殊工艺" align="center" prop="specialProcess" />
        <el-table-column label="生产工艺" align="center" prop="productionProcess" />. n/
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
            <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:info:edit']"
            >修改</el-button>
            <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:info:remove']"
            >删除</el-button>
        </template>
        </el-table-column>
    </el-table>
    
    <pagination
        v-show="total>0"
        :total="total"
        :page-sizes="[ 10, 15, 20 ]"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"/>


    </div>
</template>

<script>
import { listInfo, addInfo } from "@/api/design/info/info";

export default {
    name: "Info",
    data() {
        return {
            // base_url: import.meta.env.VITE_APP_BASE_API,
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 【请填写功能名称】表格数据
            infoList: [],
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                userName: null,
                sex: null,
                age: null,
                solarFilm: null,
                solarFilmSize: null,
                colorChangeFilm: null,
                colorChangeFilmSize: null,
                lacquerFilm: null,
                lacquerFilmSize: null,
                boxType: null,
                color: null,
                colorCustomize: null,
                colorProportion: null,
                colorProportionCustomize: null,
                style: null,
                styleCustomize: null,
                packagingReflects: null,
                specialProcess: null,
                productionProcess: null,
                status: null
            },
            // 表单参数
            form: {},
            // 表单校验
            rules: {
            },
        };
    },
    created() {
    this.getList();
    },
    methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
        this.loading = true;
        listInfo(this.queryParams).then(response => {
        this.infoList = response.rows;
        this.total = response.total;
        this.loading = false;
        });
    },
    // 取消按钮
    cancel() {
        this.open = false;
        this.reset();
    },
    // 表单重置
    reset() {
        this.form = {
        id: null,
        userName: null,
        sex: null,
        age: null,
        solarFilm: null,
        solarFilmSize: null,
        colorChangeFilm: null,
        colorChangeFilmSize: null,
        lacquerFilm: null,
        lacquerFilmSize: null,
        boxType: null,
        color: null,
        colorCustomize: null,
        colorProportion: null,
        colorProportionCustomize: null,
        style: null,
        styleCustomize: null,
        packagingReflects: null,
        specialProcess: null,
        productionProcess: null,
        createTime: null,
        status: null
        };
        this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
    },
    /** 提交按钮 */
    submitForm() {
        this.$refs["form"].validate(valid => {
        if (valid) {
            if (this.form.id != null) {
            updateInfo(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
            });
            } else {
            addInfo(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
            });
            }
        }
        });
    },
    /** 导出按钮操作 */
    handleExport() {
        this.download('system/info/export', {
        ...this.queryParams
        }, `info_${new Date().getTime()}.xlsx`)
    }
    }
};
</script>

<style scoped>
.el-input {
    width: 170px;
}
</style>
